/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q0705.java
 * @Author : WangRuoyu
 * @Date 2022/12/26 20:49
 */

package leetcode;

import java.util.ArrayList;
import java.util.List;

public class Q0705 {
    List<Integer> set;
    int count = 0;

    public Q0705() {
        set = new ArrayList<>();
    }

    public void add(int key) {
        if (set.contains(key)) {
            return;
        }
        count++;
        set.add(key);
    }

    public void remove(int key) {
        if (set.contains(key)) {
            set.remove(Integer.valueOf(key));
            count--;
        }
    }

    public boolean contains(int key) {
        if (set.contains(key)) {
            return true;
        } else {
            return false;
        }
    }

    public static void main(String[] args) {
        Q0705 sl = new Q0705();
        sl.add(1);
        sl.add(2);
        sl.add(2);
        sl.remove(2);
        System.out.println(sl.contains(2));
    }
}